package eraikikon2;

import java.awt.BorderLayout;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.Dimension;

public class TxartelaDesgaitu extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;
	
	private TxartelaDesgaitu td;
	
	private Txartela tx = null;

	/**
	 * This is the default constructor
	 */
	public TxartelaDesgaitu() {
		super();
		td = this;
		initialize();
		Box box = Box.createHorizontalBox();
		Box box1 = Box.createVerticalBox();
		Box box2 = Box.createVerticalBox();
		JLabel jLabel = new JLabel();
		final JTextField jTextField = new JTextField();
		JButton jButton = new JButton();
		box1.add(jLabel);
		box1.add(jTextField);
		box2.add(jButton);
		box.add(box1);
		box.add(box2);
		jLabel.setText("                 Txartel Kodea sartu:   ");
		jButton.setText("Ados");
		jContentPane.add(box,BorderLayout.NORTH );
		jButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				ErabKud ek = new ErabKud();
				tx = ek.getTxartela(Integer.parseInt(jTextField.getText()));
				if (tx.getId() == null){
					JOptionPane.showMessageDialog(null, "Txartel kodea ez da zuzena, saiatu berriro");
				}
				else{
					TxartelKud tk = new TxartelKud();
					tk.txDesgaitu(tx);
					td.setVisible(false);
					JOptionPane.showMessageDialog(null, "Txartela desgaitu da");
					
				}
	
			}
		});
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(301, 117);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
		}
		return jContentPane;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
